﻿/// <reference path="../GeneratedArtifacts/viewModel.js" />

myapp.trStakeholderTrainsession.created = function (entity) {
    entity.Checked = true;
    entity.RecentAttendance = "-----"

    // Teilnahmestatus
    entity.details.entitySet.dataService.AttendanceOptionsOnly()
        .filter('StaticId eq 6')        // Anwesend
        .top(1)
        .execute()
        .then(function (result) {
            if (result.results.length > 0) {
                entity.setAttendanceStatus(result.results[0]);
            }
        }, function (error) {
        }
    );

    // Teilnehmertyp
    entity.details.entitySet.dataService.StakeholderOptionsOnly()
        .filter('StaticId eq 4')    // Teilnehmer
        .top(1)
        .execute()
        .then(function (result) {
            if (result.results.length > 0) {
                entity.setAttendanceType(result.results[0]);
            }
        }, function (error) {
        }
    );
};